package tmproject.hlhj.fhp.cartrans.modules

import android.content.Context
import com.example.mymvp.BaseModule
import com.lzy.okgo.model.Response
import tmproject.hlhj.fhp.cartrans.http.Apis
import tmproject.hlhj.fhp.cartrans.http.BaseObserver
import tmproject.hlhj.fhp.cartrans.http.LoadingAction
import tmproject.hlhj.fhp.cartrans.javaBean.BaseBean
import tmproject.hlhj.fhp.cartrans.javaBean.ExamDetailBean

class ExamDetailModule:BaseModule {

    var listener:OnExamDetailListener?=null

    fun getExamDetail(c:Context,token:String?,id:Int){
        Apis.getExamDetail(token,id)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :BaseObserver<Response<ExamDetailBean>>(c){
                                override fun failed(e: Throwable?) {

                                }
                                override fun httpSuccess(t: Response<ExamDetailBean>) {
                                    listener?.gotDetail(t.body())
                                }
                                override fun httpErroCode(baseBean: BaseBean) {
                                }
                            })
                }
    }

    interface OnExamDetailListener{
        fun gotDetail(examDetailBean: ExamDetailBean)
    }
}